/*
 * Copyright (c)  2017, ueboot.com
 * All rights reserved.
 * 2017-11-04 16:54:08
 */
package com.ueboot.weishop.service.order.impl;

import com.ueboot.weishop.entity.order.OrderEntity;
import com.ueboot.weishop.entity.order.OrderExtensionEntity;
import com.ueboot.core.repository.BaseRepository;
import com.ueboot.weishop.entity.order.OrderIssueEntity;
import com.ueboot.weishop.repository.order.OrderExtensionRepository;
import com.ueboot.core.service.impl.BaseServiceImpl;
import com.ueboot.weishop.service.order.OrderExtensionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by yangkui  on 2017-11-04 16:54:08.
 *
 * @author yangkui
 * @since 2.0 by autocode
 */
@Slf4j
@Service
public class OrderExtensionServiceImpl extends BaseServiceImpl<OrderExtensionEntity> implements OrderExtensionService {
	@Autowired
	private OrderExtensionRepository orderExtensionRepository;

	@Override
	protected BaseRepository getBaseRepository() {
		return orderExtensionRepository;
	}

	/**
	 * 根据订单号查询订单扩展属性
	 *
	 * @param orderNo
	 * @return
	 */
	@Override
	public OrderExtensionEntity findByOrderNo(String orderNo) {
		return orderExtensionRepository.findByOrderNo(orderNo);
	}

	@Override
	public void saveIssueUpdateOrder(List<OrderEntity> orderList, List<OrderIssueEntity> issueList) {

	}

	/**
	 * 查询某个期次下的所有订单扩展表
	 *
	 * @param periodNum
	 * @return
	 */
	@Override
	public List<OrderExtensionEntity> findByPeriodNum(String periodNum) {
		return orderExtensionRepository.findByPeriodNum(periodNum);
	}

	@Override
	public Page<OrderExtensionEntity> findByCustomerOpenIdAndLotteryAndCategoryCode(Pageable pageable, String openId, String categoryCode, String lottery) {
		return orderExtensionRepository.findByCustomerOpenIdAndLotteryAndCategoryCode(pageable, openId, categoryCode, lottery);
	}

	@Override
	public Page<OrderExtensionEntity> findByCustomerOpenIdAndCategoryCodeAndLotteryNot(Pageable pageable, String openId, String categoryCode, String lottery) {
		return orderExtensionRepository.findByCustomerOpenIdAndCategoryCodeAndLotteryNot(pageable, openId, categoryCode, lottery);
	}

	@Override
	public Page<OrderExtensionEntity> findByCustomerOpenIdAndCategoryCode(Pageable pageable, String openId, String categoryCode) {
		return orderExtensionRepository.findByCustomerOpenIdAndCategoryCode(pageable, openId, categoryCode);
	}
}
